<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>6-4</title>
    <style>
        div {
            background-color: pink;
            height: 300px;
            width: 300px;
        }
    </style>
</head>

<body>
    <div></div>
    <script>
        var divs = document.getElementsByTagName('div'); //这个获得的一定是数组，只有一个标签也会是数组，调用时要按数组的形式来
        divs[0].onclick = function() {
            divs[0].style.backgroundColor = 'red';
            divs[0].style.width = '400px';
        }
    </script>
</body>

</html>